﻿using System;
using System.Diagnostics;
using System.Globalization;
using System.Net;
using System.Text;
using System.Threading;

namespace ConsoleApp
{
    static class Program
    {
        static void Main()
        {

            Thread t1 = new Thread(TestHandle);
            Thread t2 = new Thread(TestHandle);
            //Thread t3 = new Thread(TestHandle);
            //Thread t4 = new Thread(TestHandle);
            t1.Start();
            t2.Start();
            //t3.Start();
            //t4.Start();




            Console.ReadKey();
        }

        private static void TestWebForm()
        {
            Test("http://localhost:34438/P1.aspx?test=thanks%20for%20welcome");
        }
        private static void TestHandle()
        {
            Test("http://localhost:34660/teamsoo/about.ashx");
        }
        private static void TestMvc()
        {
            Test("http://localhost:30275/");
        }
        private static void Test(string url)
        {
            Stopwatch sw = new Stopwatch();
            sw.Start();
            WebClient wc = new WebClient { Encoding = Encoding.UTF8 };
            for (int i = 0; i < 100; i++)
            {
                wc.DownloadString(url);
            }
            wc.Dispose();
            sw.Stop();
            Console.WriteLine("所有时间：" + sw.ElapsedMilliseconds.ToString(CultureInfo.InvariantCulture));
        }
        private static void Test2(string url)
        {
            WebClient wc = new WebClient { Encoding = Encoding.UTF8 };
            for (int i = 0; i < 1; i++)
            {
                wc.DownloadString(url);
                WebHeaderCollection wh = wc.ResponseHeaders;
                foreach (string s in wh.AllKeys)
                {
                    Console.WriteLine("{0}  {1}", s, wh[s]);
                }
            }
        }

    }
}
